package com.example.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Spring Boot使用自定义的properties lcoations
 */

@Component
@ConfigurationProperties(prefix = "author",value = "classpath:config/author.properties")
public class AuthorSettings {
    private String name;
    private Long age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getAge() {
        return age;
    }

    public void setAge(Long age) {
        this.age = age;
    }
}

//新建一个 author.properties
//author.name=wolf
//author.age=28

// @ConfigurationProperties(prefix = "author",locations = "classpath:config/author.properties")
//最后注意在spring Boot入口类加上@EnableConfigurationProperties
